using System.Security.Cryptography;
using System.Text;

namespace admin_webapi.Utils
{
    public static class SignatureHelper
    {
        public static string SignWithRsa(string message, string privateKey)
        {
            using var rsa = RSA.Create();
            rsa.ImportFromPem(privateKey);
            
            byte[] data = Encoding.UTF8.GetBytes(message);
            byte[] signature = rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
            
            return Convert.ToBase64String(signature);
        }
    }
}
